<?php 
if (! defined('BASEPATH')) {
	exit('Access Denied');
}

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>下载列表</title>
<link type="text/css" href="<?php echo base_url() ;?>/static/css/bootstrap.css" rel="stylesheet" />
<link  type="text/css" href="<?php echo base_url() ;?>/static/css/bootstrap-responsive.css" rel="stylesheet" />
<link  type="text/css" href="<?php echo base_url() ;?>/static/css/extends.css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo base_url() ;?>/static/js/jquery-1.7.2.min.js"></script>
</head>



<body>
<div class="body2">
	<div class="wrap row">
		<div class="page-header">
          <h3>下载列表<small class="text-warning">---欢迎你:<?php echo isset($username)?$username:'' ;?> |<a href="<?php echo site_url('login/login_out/') ;?>">点击退出</a></small></h3>
        </div>
		<table class="table table-hover">
		  <thead>
			<tr>
			  <th>名称</th>
			  <th>点击下载</th>
			  <th>下载次数</th>
			  <th>上传时间</th>
			</tr>
		  </thead>
	  <tbody id="re">

	  </tbody>
	 <tr>
	 	<td colspan="4" align="right" id="page"></td>
	 </tr>
	</table>
	</div>
	
</div>
<script type="text/javascript" src="<?php echo base_url() ;?>/static/js/bootstrap.js"></script>
<script>
var page = 1 ;
$(function(){

	common_request(1);
});

function common_request(){
	
	var action = 'ajax_data';
	
	var url="<?php echo site_url("users/index");?>?inajax=1";
	var data_ = {

		'page':page,
		'action':'ajax'

	};
	$.ajax({
		   type: "POST",
		   url: url ,
		   data: data_,
		   cache:false,
		   dataType:"json",
		 //  async:false,
		   success: function(msg){
		
			var code = msg.resultcode ;
			
			
			result = msg.resultinfo.list.result ;
			
			var shtml = '';
			
			for(var i in result){
				
				shtml+='<tr>';
				shtml+='<td>'+result[i].filename+'</td>';
				var path = "<?php echo base_url() ;?>uploads/";
				path=path+result[i].path ;
				shtml+='<td><a onclick="down_load('+result[i].id+',\''+path+'\')" href="javascript:void(0)">点击下载</a></td>';
				shtml+='<td><strong class="text-warning">'+result[i].num+'</td>';
				shtml+='<td>'+result[i].addtime+'</td>';
				shtml+='</tr>';
			}
		
		
			$("#re").html(shtml);
			//alert();
			$("#page").html(" ");
			$("#page").html(msg.resultinfo.list.page_string);
	
		   },
		   beforeSend:function(){
			   $("#re").html("<tr bgcolor=\"#FFFFFF\" align='center' height='50'><td colspan='4'><img src='<?php echo base_url() ;?>/static/image/admin/loadding.gif'></td></tr>"); 
			   $("#page").html('');

		   },
		   error:function(){
			   alert('服务器繁忙请稍候。。。。。。');
		   }
		  
		});		
	

}
function ajax_data(p){
	page = p ;
	common_request(p);
}
function down_load(id,url){

	$.post("<?php echo site_url('users/edit_num');?>","id="+id,function(){
			common_request(page);
			window.open(url);
	});	
}
</script>
</body>
</html>